package com.zyy.smartcity1129.util;
import androidx.lifecycle.MutableLiveData;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

public class XCUtli {
    int num;
    //传入开启线程的数量
    public XCUtli(int num) {
        this.num = num;
    }

    public MutableLiveData<AtomicInteger> XCliveData=new MutableLiveData<>();
    public AtomicInteger integer=new AtomicInteger(0);
    ExecutorService execut;
    public void then(Runnable runnable){
        if (execut == null){
            execut = Executors.newFixedThreadPool(num);
        }
        execut.execute(runnable);
    }
    public void addint(){
        integer.getAndIncrement();
        XCliveData.postValue(integer);
    }
}
